package com.it.controller;

import com.alibaba.fastjson.JSON;
import com.it.pojo.MyCo;
import com.it.pojo.MyPet;
import com.it.service.MyPetService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/myPet")
@Api("swaggerDemoController相关的api")
public class MyPetController {
    @Resource
    MyPetService myPetService;

    @RequestMapping("/findPetAll")
    @ApiOperation(value = "查询所有宠物",notes = "把所有宠物按分类列出")
    public List<MyPet> findPetAll(){
    /*    List<MyPet> petAll = myPetService.findPetAll();
        String s = JSON.toJSONString(petAll);*/
        return myPetService.findPetAll();
    }

    @RequestMapping("/findPetOne/{id}")
    @ApiOperation(value = "查询单个宠物信息",notes = "根据宠物id查询详细信息")
    public MyPet findPetOne(@PathVariable("id") Integer id){
/*        MyPet petOne = myPetService.findPetOne(id);
        String s = JSON.toJSONString(petOne);*/
        return myPetService.findPetOne(id);
    }


}
